package tma.sdcbatch11.foodordering;

import java.util.ArrayList;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

public class CustomAdapter extends ArrayAdapter<Dish> {

	private Activity activity;
	private int idLayout;
	private ArrayList<Dish> list;
	
	public CustomAdapter(Activity activity, int idLayout, ArrayList<Dish> list) {
		super(activity, idLayout, list);
		this.activity = activity;
		this.idLayout = idLayout;
		this.list = list;
	}
	
	public View getView(int position, View convertView, ViewGroup parent){
		LayoutInflater infLater = activity.getLayoutInflater();
		convertView = infLater.inflate(idLayout, null);
		
		ImageView image = (ImageView)convertView.findViewById(R.id.image);
		TextView tvName = (TextView)convertView.findViewById(R.id.tv_name);
		TextView tvPhone = (TextView)convertView.findViewById(R.id.tv_cost);
		Button btnFavorite = (Button)convertView.findViewById(R.id.btn_favorite);
		Button btnRate = (Button)convertView.findViewById(R.id.btn_rate);
		Button btnCart = (Button)convertView.findViewById(R.id.btn_add_cart);
		
		tvName.setText(list.get(position).getName());
		tvPhone.setText(list.get(position).getCost());
		
		return convertView;
	}
}
